const cube = document.querySelector('.cube')
const box = document.querySelector('.box')
let  flag = false // 是否旋转模仿
const pos = {
    x:0,
    y:0
}

//e.movementX 指针和上次移动的相对距离
box.onmousemove = function(e){
    if(!flag) return
   pos.x += e.movementX
   pos.y -= e.movementY
   cube.style.transform = `rotateX(${pos.y}deg) rotateY(${pos.x}deg)`
}

// 16ms 
//0 {x:0,y:0}
//16ms {x:10,y:6} e.movementX = 10  e.movementY  = 6
//32ms {x:8 ,y :20} e.movementX = -2 e.movementY  = 14

box.onmousedown = function(){
    flag = true
    console.log('flag',flag)
}
box.onmouseup = function(){
    flag = false
}

